//
//  GHChooseOrgListViewController.m
//  ZT_iOS
//
//  Created by 周 光辉 on 2019/4/23.
//  Copyright © 2019年 Brigitte. All rights reserved.
//

#import "GHChooseOrgListViewController.h"
#import "GHChooseOrgSCell.h"
#import "NSObject+ZTNotNull.h"
#import "ApiCenter.h"
#import "ApiCenter+Comman.h"
#import "NSString+ZTUrl.h"
#import "ZTMacros.h"
#import "ZTLibTheme.h"
#import "Masonry.h"
#import "ZTHttpUrlDefine.h"
#import "MJExtension.h"
#import "AFHTTPSessionManager.h"
#import "UIViewController+ZTHUD.h"
#import "UserModel.h"
#import "ZTLoadZYHTMLViewController.h"
#import "ZTUserInfoManage.h"
//#import "GHAllNotesViewController.h"

#import "ZTNoPermissionsViewController.h"
//#import "TSMClientManger.h"
//#import "LoginingViewController.h"
//#import "VDUservice.h"
@interface GHChooseOrgListViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UILabel *textLabel;
@property (nonatomic,strong)UIButton *okBtn;
@property (nonatomic)NSInteger index;
@property (nonatomic,strong)NSString *oneStr;


@end

@implementation GHChooseOrgListViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

-(void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}

-(UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.font = ZTFONT(24);
        _titleLabel.text = @"请选择您的组织单位";
        _titleLabel.textColor = [UIColor textColor];
        _titleLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _titleLabel;
}

-(UILabel *)textLabel
{
    if (!_textLabel) {
        _textLabel = [UILabel new];
        _textLabel.font = ZTFONT(12);
        _textLabel.text = @"登录后可在“我的->所属部门”中进行修改";
        _textLabel.textColor = [UIColor textFieldTextColor];
        _textLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _textLabel;
}

-(UIButton *)okBtn
{
    if (!_okBtn) {
        _okBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_okBtn setTitle:@"完成" forState:UIControlStateNormal];
        [_okBtn setTitleColor:[UIColor themeColor] forState:UIControlStateNormal];
        [_okBtn addTarget:self action:@selector(okClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _okBtn;
}
#pragma mark -- 完成
- (void)okClick
{
    NSDictionary *dic = _model.msgList[_index];
    NSString * pdid = [dic objectForKey:@"pdId"];
    NSLog(@"pdId = %@",pdid);
    [self selecPdId:pdid Success:^(BaseModel *model) {
        [self addDataWithModel:model];
        
    } failure:^(ErrorModel *model) {
//        [self showHUDOnlyText:model.message];
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    for (NSDictionary *dic in _model.msgList) {
        if ([[dic objectForKey:@"majorDept"] isEqual:@"1"]) {
            _oneStr = [dic objectForKey:@"pdId"];
        }
    }
    NSLog(@"%@\n%@",self.model.msgList,self.oneStr);
    if (@available(iOS 11.0,*)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else{
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.right.and.left.and.bottom.equalTo(self.view);
    }];
    [self.navigationController setNavigationBarHidden:YES];;

}

-(UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource =self;
        _tableView.estimatedRowHeight = 115;
        _tableView.rowHeight = UITableViewAutomaticDimension;
        _tableView.separatorStyle = UITableViewCellSelectionStyleNone;//隐藏分割线
        [_tableView registerClass:[GHChooseOrgSCell class] forCellReuseIdentifier:NSStringFromClass([GHChooseOrgSCell class])];
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([self class])];
    }
    return _tableView;
}

#pragma mark --tableView delagate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _model.msgList.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 120;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView * head = [UIView new];
    head.backgroundColor = [UIColor whiteColor];
    self.titleLabel.frame  = CGRectMake(12, statusHeight + 25, Main_Screen_Width-24, 30);
    self.textLabel.frame  = CGRectMake(12, statusHeight + 55, Main_Screen_Width-24, 30);
    self.okBtn.frame  = CGRectMake(Main_Screen_Width - 62, statusHeight + 35, 50, 30);

    [head addSubview:self.titleLabel];
    [head addSubview:self.textLabel];
    [head addSubview:self.okBtn];

    return head;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic = _model.msgList[indexPath.row];
    GHChooseOrgSCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([GHChooseOrgSCell class]) forIndexPath:indexPath];
    if (cell == nil) {
        cell = [[GHChooseOrgSCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([GHChooseOrgSCell class])];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if ([dic[@"deptName"] isNotNull]) {
        cell.orgLabel.text = [dic objectForKey:@"deptName"];
    }
    if ([dic[@"position"] isNotNull]) {
        cell.depLabel.text = [dic objectForKey:@"position"];
    }
    NSBundle *associateBunle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"ZTPrivateLib" ofType:@"bundle"]];
    if ([[dic objectForKey:@"pdId"] isEqualToString:_oneStr]) {
        _index = indexPath.row;
        cell.seleImageView.image = [UIImage imageNamed:@"selewhiteorg_s"
                                              inBundle: associateBunle
                     compatibleWithTraitCollection:nil];
    }else{
        cell.seleImageView.image = [UIImage imageNamed:@"selewhiteorg_n"
                                              inBundle: associateBunle
                     compatibleWithTraitCollection:nil];
    }
    
    return cell;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic = _model.msgList[indexPath.row];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    _oneStr = [dic objectForKey:@"pdId"];
    _index = indexPath.row;
//    GHChooseOrgSCell * cell = (GHChooseOrgSCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];//即为要得到的cell
//    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:indexPath.row inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
    [self.tableView reloadData];

}

- (void)addDataWithModel:(BaseModel *)model
{
//    WEAK_SELF;
//    //判断是不是切换帐号了
    UserModel *userModel = [UserModel mj_objectWithKeyValues:model.msg];
        /** 保存使用的登录用户账号信息   替换成自己项目中的账号信息  项目登录成功以后共享登录信息  便于其他功能跳转*/
    NSDictionary *dict = @{
        @"userAccount":userModel.account,   //用户账号
        @"userName":userModel.account,      //用户名
        @"userPdId":userModel.pdId,     //部门id
        @"userId":userModel.uid,       //用户id
    };
    [[NSUserDefaults standardUserDefaults]setObject:dict forKey:ZTPrivateUserInfoKey];
    [[NSUserDefaults standardUserDefaults]synchronize];
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:userModel.token forKey:APPDeviceToken];
    [userDefaults synchronize];
    
    
    [self checkZtprivatePermissAuthcode:@"hand_2" ZTPrivatejsonDict:self.ztjsonDict];
    
    
//    if ([[model.msg objectForKey:@"telePhone"] isNotEmpty]) {
//        userModel.telephone = [model.msg objectForKey:@"telePhone"];
//    }else{
//        userModel.telephone = @"";
//    }
//    NSLog(@"-----%@----%@",model.msg,userModel.token);
//
//    if ([userModel.account isEqualToString:[[LoginUserService defaultService] getLoginUserAccount]]) {
//        DLog(@"未切换帐号");
//    }else{
//        DLog(@"切换账号了");//需要重新加载通讯录
//        [[NSUserDefaults standardUserDefaults]removeObjectForKey:fristCreateAppKey];
//        [[NSUserDefaults standardUserDefaults]removeObjectForKey:addFristCreateAppKey];
//    }
//    FMDBHandle *fmdbHandle = [FMDBHandle shareHandle];
//    [fmdbHandle openDataBase];
//    [fmdbHandle createOrgContactsPersonTable];
//    [fmdbHandle insertOrgContactsPerson:userModel];
//    [fmdbHandle closeDataBase];
//    [[LoginUserService defaultService] saveLoginUserInfo:model.msg];
////    [[LoginUserService defaultService]setLoginUserPdIdArray:self.model.msgList];
//    [[LoginUserService defaultService]savePassWord:self.pwd];
//    //保存加密之后的密码
//    [[LoginUserService defaultService]saveSecretPassWord:userModel.password];
////    [self dismissViewControllerAnimated:YES completion:^{
//    ZT_AppDelegate.isLogCallMeet = YES;
//    /** 获取权限*/
//    [self queryuserpermissions];
//    [weakSelf showHudInView:weakSelf.view hint:@"登录中..."];
//        [[TSMClientManger sharedManager] loginWithUsername:userModel.account password:userModel.password withSuccessBlock:^{
//            [weakSelf hideHud];
//            LoginingViewController *loginingC = [LoginingViewController new];
//            loginingC.userModel = userModel;
//            [weakSelf.navigationController pushViewController:loginingC animated:YES];
//
//        } withFailureBlock:^{
//            [weakSelf hideHud];
//        }];
//    }];
    
}

#pragma mark - 检测用户是否有wps 权限
-(void)queryuserpermissions
{
    [[NSUserDefaults standardUserDefaults]setObject:@"" forKey:@"wps_ssoforKey"];
    [[NSUserDefaults standardUserDefaults]synchronize];
    
//    [[VDUservice shareDUservice] getAppCenterByCodepdId:[[LoginUserService defaultService] getLoginUserPdId]?[[LoginUserService defaultService] getLoginUserPdId]:@"" success:^(id model) {
//
//        NSDictionary *dict = [model mj_JSONObject];
//        NSMutableArray *msgArray = [[NSMutableArray alloc]initWithArray:[dict objectForKey:@"msg"]];
//
//        for (NSDictionary *dict in msgArray) {
//
//            if ([[dict objectForKey:@"appCode"] isEqualToString:@"wps_sso"]) {
//
//                [[NSUserDefaults standardUserDefaults]setObject:@"wps_sso" forKey:@"wps_ssoforKey"];
//                [[NSUserDefaults standardUserDefaults]synchronize];
//            }
//        }
//
//        NSLog(@"输出 == %@",[model mj_JSONObject]);
//
//    } fail:^(ErrorModel *model) {
//
//
//    }];
  
    
}

- (void)selecPdId:(NSString *)pdid Success:(ApiCenterSuccessBlock)success failure:(ApiCenterFailureBlock)failure
{
    
    NSString *urlString = [NSString stringWithFormat:@"http://zhbg.zhtchina.net:8280/masCustomer/service/UserInfoService/loginByPdid"];
    NSDictionary *paramDic = @{@"deviceId": @"ios",
                               @"pdId":pdid
    };
    AFHTTPSessionManager *manager =[AFHTTPSessionManager manager];
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", @"text/css", @"text/xml", @"text/plain", @"application/javascript", @"application/x-www-form-urlencoded", @"image/*", nil];

    //发送请求
    [manager POST:urlString parameters:paramDic headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dict = [responseObject mj_JSONObject];
        NSLog(@"输出  dict == %@",dict);
        BaseModel *model = [BaseModel mj_objectWithKeyValues:dict];
        success(model);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [[[[UIApplication sharedApplication]keyWindow] rootViewController] showHUDOnlyText:error.localizedDescription];

    }];

}


-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

#pragma mark  检查是否有权限问题
/**
 @brief
 检查是否有权限问题
 *
 */
-(void)checkZtprivatePermissAuthcode:(NSString *)authcode ZTPrivatejsonDict:(NSDictionary *)ztjsonDict{

    NSString *urlString = [NSString stringWithFormat:@"http://zhbg.zhtchina.net:8280/masCustomer/service/appPrivileges/getAppCenterByCode"];
    NSDictionary *paramDic = @{@"deviceId": @"ios",
                               @"code":@"hand_2",
                               @"pdId":[[ZTUserInfoManage defaultService] getLoginUserPdId],
    };
    AFHTTPSessionManager *manager =[AFHTTPSessionManager manager];
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", @"text/css", @"text/xml", @"text/plain", @"application/javascript", @"application/x-www-form-urlencoded", @"image/*", nil];

    //发送请求
    [manager POST:urlString parameters:paramDic headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dict = [responseObject mj_JSONObject];
        if ([[dict objectForKey:@"msg"] isNotEmpty]) {
            
            NSMutableArray *msgArray = [dict objectForKey:@"msg"];
            NSMutableArray *msgStringAry = [msgArray valueForKey:@"appName"];


            NSString *ztprivatetype = [ztjsonDict objectForKey:@"type"];
            NSString *titleString = @"";
            if ([ztprivatetype isEqualToString:@"inspector_has_chosen"]) {
                titleString = @"督查督办";
            }else if ([ztprivatetype isEqualToString:@"transport_management"]){
                titleString = @"用车管理";
            }else if ([ztprivatetype isEqualToString:@"document_center"]){
                titleString = @"文档中心";
            }else if ([ztprivatetype isEqualToString:@"news"]){
                titleString = @"新闻";
            }else if ([ztprivatetype isEqualToString:@"transaction_management"]){
                titleString = @"事务管理";
            }else if ([ztprivatetype isEqualToString:@"to_do"]){
                titleString = @"待办";
            }else if ([ztprivatetype isEqualToString:@"announcement"]){
                titleString = @"公告";
            }else if ([ztprivatetype isEqualToString:@"official_document"]){
                titleString = @"公文";
            }else if ([ztprivatetype isEqualToString:@"duty_management"]){
                titleString = @"值班管理";
            }else if ([ztprivatetype isEqualToString:@"assets_management"]){
                titleString = @"资产管理";
            }else if ([ztprivatetype isEqualToString:@"contract_management"]){
                titleString = @"合同管理";
            }
            if ([msgStringAry containsObject:titleString]) {
                [self pushZtprivateWebVc:ztjsonDict];
            }else{
                [self ztnopermisspushVCTitle:titleString];
            }
            
            
        }else{
            [[[[UIApplication sharedApplication]keyWindow] rootViewController] showHUDOnlyText:@"暂无权限"];
        }
        NSLog(@"输出  responseObject == %@",responseObject);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [[[[UIApplication sharedApplication]keyWindow] rootViewController] showHUDOnlyText:error.localizedDescription];

    }];



}

- (void)pushZtprivateWebVc:(NSDictionary *)ztjsonDict{
    
    NSString *ztprivatetype = [ztjsonDict objectForKey:@"type"];
    if ([ztprivatetype isEqualToString:@"inspector_has_chosen"]) {
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"url":[NSString stringWithFormat:@"http://111.206.218.241:8080/seeyon/m3/apps/v5/biz/html/bizInfo.html?menuId=6660106445562069148&name=%@",[[ZTUserInfoManage defaultService]getLoginUserName]]
        };
        //督查督办
        [GHChooseOrgListViewController openSingleH5MethodsWithParaDic:dict];
        
        
    }else if ([ztprivatetype isEqualToString:@"transport_management"]){
        //用车管理
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"url":[NSString stringWithFormat:@"http://111.206.218.241:8080/seeyon/m3/apps/v5/biz/html/bizInfo.html?menuId=8672116713043215757&name=%@",[[ZTUserInfoManage defaultService]getLoginUserName]],
        };
   
        [GHChooseOrgListViewController openSingleH5MethodsWithParaDic:dict];
        
    }else if ([ztprivatetype isEqualToString:@"document_center"]){
       
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"appCode":@"doc"
        };
        //文档中心
        NSString *ipString;
        if ([dict.allKeys containsObject:@"ip"]) {
            ipString = dict[@"ip"];
        }
        
        ZTLoadZYHTMLViewController * html = [[ZTLoadZYHTMLViewController alloc] init];
       
//        NSString * urlTest = [ipString stringByAppendingFormat:ZYLOGIN_URI, [[ZTUserInfoManage defaultService] getLoginUserAccount]];
        html.hostUrlString =ipString;
        html.url =  [html.hostUrlString stringByAppendingFormat:ZYWENDANGZHONGXIN_URI];
        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        
        
//        ZTWebViewController * html = [[ZTWebViewController alloc] init];
//        html.hostUrlString = ipString;
//        html.urlString = [html.hostUrlString stringByAppendingFormat:ZYWENDANGZHONGXIN_URI];
//        html.title = [dict objectForKey:@"appName"];
//        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        

        
        
    }else if ([ztprivatetype isEqualToString:@"news"]){
        
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"appCode":@"news"
        };
        //新闻
        NSString *ipString;
        if ([dict.allKeys containsObject:@"ip"]) {
            ipString = dict[@"ip"];
        }
        ZTLoadZYHTMLViewController * html = [[ZTLoadZYHTMLViewController alloc] init];
       
//        NSString * urlTest = [ipString stringByAppendingFormat:ZYLOGIN_URI, [[ZTUserInfoManage defaultService] getLoginUserAccount]];
        html.hostUrlString =ipString;
        html.url = [html.hostUrlString stringByAppendingFormat:ZYREDIRECT_URI];;
        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        
//        ZTWebViewController * html = [[ZTWebViewController alloc] init];
//        html.hostUrlString = ipString;
//    //        html.hostUrlString = @"http://130.120.110.122";
//        html.urlString = [html.hostUrlString stringByAppendingFormat:ZYREDIRECT_URI];
//        html.title = [dict objectForKey:@"appName"];
//        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        
        
    }else if ([ztprivatetype isEqualToString:@"transaction_management"]){
        
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"appCode":@"collaboration"
        };
        //事务管理
        NSString *ipString;
        if ([dict.allKeys containsObject:@"ip"]) {
            ipString = dict[@"ip"];
        }
        
        ZTLoadZYHTMLViewController * html = [[ZTLoadZYHTMLViewController alloc] init];
       
//        NSString * urlTest = [ipString stringByAppendingFormat:ZYLOGIN_URI, [[ZTUserInfoManage defaultService] getLoginUserAccount]];
        html.hostUrlString =ipString;
        html.url = [html.hostUrlString stringByAppendingFormat:ZYSHIWU_URI];
        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        
        
//        ZTWebViewController * html = [[ZTWebViewController alloc] init];
//        html.hostUrlString = ipString;
//        html.urlString = [html.hostUrlString stringByAppendingFormat:ZYSHIWU_URI];
//        html.title = [dict objectForKey:@"appName"];
//        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        
        
    }else if ([ztprivatetype isEqualToString:@"to_do"]){
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"appCode":@"daiban"
        };
        //待办
        NSString *ipString;
        if ([dict.allKeys containsObject:@"ip"]) {
            ipString = dict[@"ip"];
        }
        
        ZTLoadZYHTMLViewController * html = [[ZTLoadZYHTMLViewController alloc] init];
       
//        NSString * urlTest = [ipString stringByAppendingFormat:ZYLOGIN_URI, [[ZTUserInfoManage defaultService] getLoginUserAccount]];
        html.hostUrlString =ipString;
        html.url =  [ipString stringByAppendingFormat:ZYDAIBAN_URI];
        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
//        ZTWebViewController * html = [[ZTWebViewController alloc] init];
//        html.hostUrlString = ipString;
//        html.urlString = [ipString stringByAppendingFormat:ZYDAIBAN_URI];
//        html.title = [dict objectForKey:@"appName"];
//        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        
        
    }else if ([ztprivatetype isEqualToString:@"announcement"]){
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"appCode":@"bulletin"
        };
        //公告
        NSString *ipString;
        if ([dict.allKeys containsObject:@"ip"]) {
            ipString = dict[@"ip"];
        }
        ZTLoadZYHTMLViewController * html = [[ZTLoadZYHTMLViewController alloc] init];
       
//        NSString * urlTest = [ipString stringByAppendingFormat:ZYLOGIN_URI, [[ZTUserInfoManage defaultService] getLoginUserAccount]];
        html.hostUrlString =ipString;
        html.url =  [ipString stringByAppendingFormat:ZYGONGGAO_URI];
        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
//        ZTWebViewController * html = [[ZTWebViewController alloc] init];
//        html.hostUrlString = ipString;
//        html.urlString = [ipString stringByAppendingFormat:ZYGONGGAO_URI];
//        html.title = [dict objectForKey:@"appName"];
//        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        
        
    }else if ([ztprivatetype isEqualToString:@"official_document"]){
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"appCode":@"gongwen"
        };
        //公文
        NSString *ipString;
        if ([dict.allKeys containsObject:@"ip"]) {
            ipString = dict[@"ip"];
        }
        
        ZTLoadZYHTMLViewController * html = [[ZTLoadZYHTMLViewController alloc] init];
       
//        NSString * urlTest = [ipString stringByAppendingFormat:ZYLOGIN_URI, [[ZTUserInfoManage defaultService] getLoginUserAccount]];
        html.hostUrlString =ipString;
        html.url =  [html.hostUrlString stringByAppendingFormat:ZYZHENGWEN_URI];
        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        
//        ZTWebViewController * html = [[ZTWebViewController alloc] init];
//        html.hostUrlString = ipString;
//    //        html.hostUrlString = @"http://130.120.110.122";
//        html.urlString = [html.hostUrlString stringByAppendingFormat:ZYZHENGWEN_URI];
//        html.title = [dict objectForKey:@"appName"];
//        [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
        
        
    }else if ([ztprivatetype isEqualToString:@"duty_management"]){
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"url":[NSString stringWithFormat:@"http://111.206.218.241:8080/seeyon/m3/apps/v5/biz/html/bizInfo.html?menuId=1517303629883720370&name=%@",[[ZTUserInfoManage defaultService]getLoginUserName]],
        };
        //值班管理
        [GHChooseOrgListViewController openSingleH5MethodsWithParaDic:dict];

        
        
    }else if ([ztprivatetype isEqualToString:@"assets_management"]){
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"url":[NSString stringWithFormat:@"http://111.206.218.241:8080/seeyon/m3/apps/v5/biz/html/bizInfo.html?menuId=1312597677305907543&name=%@",[[ZTUserInfoManage defaultService]getLoginUserName]],
        };
        //资产管理
        [GHChooseOrgListViewController openSingleH5MethodsWithParaDic:dict];

        
        
    }else if ([ztprivatetype isEqualToString:@"contract_management"]){
        NSDictionary *dict = @{
            @"ip":@"http://111.206.218.241:8080",
            @"url":[NSString stringWithFormat:@"http://111.206.218.241:8080/seeyon/m3/apps/v5/biz/html/bizInfo.html?menuId=-5409992764838949920&name=%@",[[ZTUserInfoManage defaultService]getLoginUserName]]
        };
        //合同管理
        [GHChooseOrgListViewController openSingleH5MethodsWithParaDic:dict];
    }else {
        [[[[UIApplication sharedApplication]keyWindow] rootViewController] showHUDOnlyText:@"请传输正确的功能模块的type类型"];
    }

}


#pragma mark- ------ 纯网址跳转需要单点登录 ------
+ (void)openSingleH5MethodsWithParaDic:(NSDictionary *)dict{
    
    ZTLoadZYHTMLViewController * html = [[ZTLoadZYHTMLViewController alloc] init];
    html.hostUrlString = dict[@"ip"];
    html.url = dict[@"url"];
    [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:html animated:YES];
}


-(void)ztnopermisspushVCTitle:(NSString *)title
{
    ZTNoPermissionsViewController *ztnopermiss = [[ZTNoPermissionsViewController alloc]init];
    ztnopermiss.navigationTitle = title;
    [(UINavigationController *)[[UIApplication sharedApplication]keyWindow].rootViewController pushViewController:ztnopermiss animated:YES];

}


@end
